#include "../RealtimeUI/WebsocketClient.hpp"
#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <fstream>

WebsocketClinet* ws;
std::ofstream outputFile("outputData.avi",std::ios::binary | std::ios::trunc);
void Handle_data(const char* data,std::size_t size)
{
  std::cout<<"获取到一组数据，大小为"<<size<<std::endl;
  outputFile.write(data,size);
  ws->WriteText("1",1);
}

void Handle_SIGINT(int)
{

}

int main()
{
  if(!outputFile.is_open())
    throw;
  signal(SIGINT,Handle_SIGINT);
  ws=new WebsocketClinet("http://192.168.1.52:10090","/Handle/Stream");
  ws->BootReadCallback(Handle_data);
  ws->WriteText("1",1);
  while(true)
  {
    if(sleep(10)!=0)
      break;
  }
  delete ws;
}
